//
//  ComplainTypeArrModel.swift
//  Pods
//
//  Created by eme on 2017/4/7.
//
//

import Foundation
import SwiftyJSON
import NetWorkCore
import ModelProtocol

class ComplainTypeArrModel: ModelProtocol {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    internal let kComplainTypeComplainTypeKey: String = "complainType"
    
    
    // MARK: 属性
    var complainType: [ComplainTypeModel]
    
    
    // MARK: 实现MikerSwiftJSONAble 协议， 解析json数据
    required  init?(json: JSON) {
        complainType = []
        if let items = json[kComplainTypeComplainTypeKey].array {
            for item in items {
                if let complainTypeModel = ComplainTypeModel(json: item){
                    complainType.append(complainTypeModel)
                }
            }
        } else {
            complainType = []
        }
        
    }
    
    
    /**
     Generates description of the object in the form of a NSDictionary.
     - returns: A Key value pair containing all valid values in the object.
     */
    internal func dictionaryRepresentation() -> [String : AnyObject ] {
        
        var dictionary: [String : AnyObject ] = [ : ]
        if complainType.count > 0 {
            var temp: [AnyObject] = []
            for item in complainType {
                temp.append(item.dictionaryRepresentation() as AnyObject)
            }
            dictionary.updateValue(temp as AnyObject, forKey: kComplainTypeComplainTypeKey)
        }
        
        return dictionary
    }
    
    
}
